<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title></title>
    <link href="../css/scroll.css" rel="stylesheet">
    <link rel="stylesheet" href="../css/idangerous.swiper.css">
    <link rel="stylesheet" href="../css/base.css">
    <script src="../js/flexible.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/idangerous.swiper.min.js"></script>
    <script src="../js/downLode.js"></script>
    <script type="text/javascript">
    window.onload = function(){
            var oBox = document.getElementById('box');
            var oLIst1 = document.getElementById('list1');
            var aLi1 = oLIst1.getElementsByTagName('li');
            //第一张的初始透明度设置不透明
            aLi1[0].style.opacity = 1;
            aLi1[0].style.filter = 'alpha(opacity=100)';
            var size = aLi1.length;
            var i = 0;
            //图片透明度变换的定时器
            var timer = setInterval(function(){
                i ++;
                move();
            },3000)
            function move(){
                //临界值
                if( i >= size ){
                    i = 0;
                }
                //透明度切换
                for(var j = 0; j < aLi1.length; j ++){
                    if(j == i){
                        animate(aLi1[j],{opacity:100});
                    }else{
                        animate(aLi1[j],{opacity:0});
                    }
                }
            }
            /*************************缓冲运动        可封装留着以后备用^_^*************************/
         function getStyleAttr(obj, attr){
                if (window.getComputedStyle){
                    return getComputedStyle(obj, null)[attr];
                }
                else {
                    return obj.currentStyle[attr];
                }
            }
            function animate(obj, json, fn){
                clearInterval(obj.timer);
                obj.timer = setInterval(function(){
                    var bStop = true;
                    for (var attr in json){
                        var iTarget = json[attr];
                        var current;
                        if (attr == "opacity"){
                            current = parseFloat(getStyleAttr(obj, attr))*100;
                            current = Math.round(current);
                        }
                        else {
                            current = parseFloat(getStyleAttr(obj, attr));
                            current = Math.round(current);
                        }
                        var speed = (iTarget-current)/8;    (400-393)/8
                        speed = speed>0 ? Math.ceil(speed) : Math.floor(speed);
                        if (current != iTarget){
                            bStop = false;
                        }
                        if (attr == "opacity"){
                            obj.style[attr] = (current+speed)/100;
                            obj.style.filter = "alpha(opacity=" + (current+speed) + ")";
                        }
                        else {
                            obj.style[attr] = current+speed + "px";
                        }
                    }
                    if (bStop){
                        console.log("停止运动");
                        clearInterval(obj.timer);
                        if (fn) {
                            fn();
                        }
                    }
                }, 30);
            }
        }
    </script>
</head>
<body>
<div id="box">
   <ul id="list1">
        <li class="img1">
            <!--<img src="../images/11.jpg" alt="" id="img">-->
        </li>
        <li class="img2">
            <!--<img src="images/22.jpg" alt="">-->
        </li>
        <li class="img3">
            <!--<img src="images/33.jpg" alt="">-->
        </li>
        <li class="img4">
            <!--<img src="images/44.jpg" alt="">-->
        </li>
    </ul>
 <div class="device">
     <h4>秘密情人</h4>
        <div class="swiper-container">
            <ul class="swiper-wrapper">
                <li class="swiper-slide">
                    <p><span>1vs1</span>方圆之间 此地只有你我</p>
                </li>
                <li class="swiper-slide" >
                    <p><span>真实性</span>两情相悦 现实交友亦可</p>
                </li>
                <li class="swiper-slide" >
                    <p><span>主播多</span>环肥燕瘦 三千主播任选</p>
                </li>
                <li class="swiper-slide" >
                    <p><span>尺度大</span>春宵一刻 美女任君采撷</p>
                </li>
            </ul>
        </div>

        <div class="pagination"></div>
    </div>
    <h3 id="downLode">挑选我的专属情人</h3>
</div>

<script>
   $(function(){
        var mySwiper = new Swiper('.swiper-container',{
            pagination: '.pagination',
            loop:true,
            grabCursor: true,
            paginationClickable: true,
            autoplay : 3000,
            autoplayDisableOnInteraction : false
        })

       /*预加载图片*/
       function preloader() {
           if (document.images) {
               var img1 = new Image();
               var img2 = new Image();
               var img3 = new Image();
               var img4 = new Image();
               img1.src = "../images/11.jpg";
               img2.src = "../images/22.jpg";
               img3.src = "../images/33.jpg";
               img4.src = "../images/44.jpg";
//               console.log(img1);
           }
       }

       function addLoadEvent(func) {
           var oldonload = window.onload;
           if (typeof window.onload != 'function') {
               window.onload = func;
           } else {
               window.onload = function() {
                   if (oldonload) {
                       oldonload();
                   }
                   func();
               }
           }
       }
       addLoadEvent(preloader);

    });
</script>

</body>
</html>
